<template>
  <view>
    <view class="cu-list menu" v-show="loading">
      <view class="margin-xs padding-sm flex align-center shadow-blur bg-white radius" style="overflow: hidden" @tap="goToUrl('authentication')">
        <view class="padding text-xxlx">
          <text class="cuIcon cuIcon-profile text-blue"></text>
        </view>
        <view class="flex-sub text-left">
          <view class="text-bold">
            <text>个人认证</text>
          </view>
          <view class="text-grey text-sm">完成认证后才可以进行提现</view>
        </view>
        <view class="action">
          <text class="name bg-black text-white" v-if="user.shiming == 0">未认证</text>
          <text class="name bg-green text-white" v-else>已认证</text>
        </view>
      </view>
      <view class="margin-xs padding-sm flex align-center shadow-blur bg-white radius" style="overflow: hidden" @tap="goToUrl('enterprise')">
        <view class="padding text-xxlx">
          <text class="cuIcon cuIcon-punch text-blue"></text>
        </view>
        <view class="flex-sub text-left">
          <view class="text-bold">
            <text>企业认证</text>
          </view>
          <view class="text-grey text-sm">完成认证可以对接API通过接口核销卡密</view>
        </view>
        <view class="action">
          <text class="name bg-green text-white" v-if="user.shiming == 2">已认证</text>
          <text class="name bg-black text-white" v-else>未认证</text>
        </view>
      </view>
    </view>
  </view>
</template>
<script>
export default {
  data() {
    return {
      loading: false,
      user: []
    };
  },
  onLoad() {
    uni.showLoading({
      title: '加载中...'
    });
    this.getUser();
  },
  onShow() {
    this.getUser();
  },
  methods: {
    goToUrl(e) {
      uni.navigateTo({
        url: e
      });
    },
    getUser() {
      var that = this;
      uni.request({
        url: that.app.apiHost + '/mindex',
        method: 'POST',
        header: { Authorization: 'bearer ' + that.app.getAuthCode() },
        success: (res) => {
          console.log(res.data);
          if (res.data.code == -1) {
            that.app.showMsg('请登陆后再操作!', '../login/login');
          }
          if (res.data.code == 0) {
            uni.setStorageSync('users', JSON.stringify(res.data.data));
            that.user = res.data.data;
            uni.hideLoading();
            that.loading = true;
          }
        },
        fail(res) {}
      });
    }
  }
};
</script>

<style>
page {
  background-color: #f1f1f1;
}
.name {
  width: 100px;
  height: 20px;
  line-height: 20px;
  position: absolute;
  right: -30px;
  top: 15px;
  text-align: center;
  font-size: 12px;
  display: block;
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
}
</style>
